﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Objects;
using MovieRental.Entities;

namespace MovieRental.EfRepositoryLibrary.Mappers
{
    public class MovieMapper : BaseMapper<MovieInfo, Guid, Movie, Movie, MovieRentalEntitiesContainer>
    {
        public override void Convert(MovieInfo entity, Movie model)
        {
            model.Id = entity.Id;
            model.Title = entity.Title;
            model.ImdbRating = entity.ImdbRating;
            model.WebPage = entity.WebPage;
        }

        public override void ConvertBack(Movie model, MovieInfo entity)
        {
            entity.Id = model.Id;
            entity.Title = model.Title;
            entity.ImdbRating = model.ImdbRating;
            entity.WebPage = model.WebPage;
        }

        public override Guid SelectKey(Movie model)
        {
            return model.Id;
        }

        public override Guid SelectKey(MovieInfo entity)
        {
            return entity.Id;
        }

        public override ObjectSet<Movie> SelectObjectSet(MovieRentalEntitiesContainer context)
        {
            return context.Movies;
        }
    }
}
